package red.book._1._1;

import java.util.Arrays;

import edu.princeton.cs.algs4.StdIn;
import red.book.until.In;
import red.book.until.StdOut;

public class BinarySearchSimple {
	public static int rank(int key, int[] a) {
		if(a.length == 0) {
			return -1;
		}
		int start = 0;
		int end = a.length - 1;
		int mid = (start + end) /2;
		
		while(start <= end) {
			if(a[mid] < key) {
				start = mid + 1;
			}else if(a[mid] > key) {
				end = mid - 1;
			}else {
				return mid;
			}
		}
		return -1;
	}
	
	@SuppressWarnings("deprecation")
	public static void main(String[] args) {
		int[] whitelist = In.readInts(args[0]);
		Arrays.sort(whitelist);
		while(!StdIn.isEmpty()) {
			int key = StdIn.readInt();
			if(rank(key, whitelist) < 0) {
				StdOut.println(key);
			}
		}
	}

}
